package com.huey.utils.design.structure.proxy.demo2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 黄雀
 * @author xubo
 * @date 2022/3/30 14:10
 */
public class Cardinal implements InvocationHandler {

    private Object proxyOne;

    public Cardinal(Object proxyOne) {
        this.proxyOne = proxyOne;
    }

    /**｝
     * 螳螂主要业务，也就是监听对象
     * @param proxy
     * @param method
     * @param args
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        method.invoke(proxyOne, args);
        secondaryMain();
        return null;
    }


    private void secondaryMain() {
        System.out.println("黄雀吃螳螂 - 次要业务");
    }


}
